package com.example.helloworld;

import com.example.helloworld.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class MainAbility extends Ability {

    // 定义HiLogLabel静态对象
    static final HiLogLabel loglabel = new HiLogLabel(HiLog.LOG_APP, 0x00101, "测试");

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(MainAbilitySlice.class.getName());
        // 通过HiLog的info静态方法输出“您好,HiLog!”字符串
        HiLog.info(loglabel, "您好,HiLog!");
        // HiLog的格式化输出
        HiLog.warn(loglabel, "Failed to visit %{private}s, reason:%{public}d.", "https://www.baidu.com", 404);
		
		// 整型数组
		int[] intArray = {1,2,3,2,3,4,3,4,5};
		String strOutput = "";
		for (int value : intArray) {
			strOutput += " " + value;
		}
		HiLog.info(loglabel, "Integer Array:" + strOutput);

		// HashMap键值对数据
		Map personInformation = new HashMap();
		personInformation.put("name", "David");
		personInformation.put("age", "26");
		personInformation.put("sex", "male");
		personInformation.put("height", "175cm");
		HiLog.info(loglabel, "HashMap: " + personInformation.toString()); // 可在此处添加断点
		
		for(int i = 0; i < 10; i++) {
			int j = i * 2;
			HiLog.info(loglabel, "i的值为%{public}d, j的值为%{public}d.", i, j); // 在此处添加断点
		}
}



    }
}
